home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 January / Disc 3 / Amethyst.iso / rl / build-bin / createupdatesets < prev    next >
Encoding:
Text File  |  2001-06-26  |  2.6 KB  |  127 lines

  1. #!/bin/sh
  2. # createupdatesets - create the necessary file to support the rlupdate
  3. # stage 2 / software installer program
  4. # copyright (c) 2001 Joseph Cheek, Redmond Linux Corp.  Released under
  5. # GPL.
  6.  
  7. UPDATEBASEDIR=.
  8. RPMSBASEDIR=.
  9.  
  10.  
  11. _getrpmlist() {
  12. #return a list of all RPM files in dir $1
  13.  
  14.   ls "$1/"*.rpm | cat
  15.  
  16. }
  17.  
  18.  
  19. _createupdatesets_xml() {
  20.  
  21.  
  22. __createupdates_header() {
  23.  
  24. cat << EOF
  25. <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE updatesets ><updatesets>
  26. EOF
  27.  
  28. }
  29.  
  30.  
  31. __createupdates_body() {
  32. # create the body for package $1 according to the following pattern:
  33.  
  34. # <updateset size="15450" name="hwprobe" >
  35. #  <prescript><![CDATA[]]></prescript>
  36. #  <postscript><![CDATA[]]></postscript>
  37. #  <package query="hwprobe" size="15450" arch="i586" action="install"
  38. #  version="0.1-35rl" name="Automatic detection of PCI and ISAPNP devices." >
  39. #   <prescript><![CDATA[]]></prescript>
  40. #   <postscript><![CDATA[]]></postscript>
  41. #  </package>
  42. # </updateset>
  43.  
  44. _UP_SIZE=`ls -l $1 | tr -s \  | cut -d \  -f 5`
  45. _UP_NAME=`rpmextr --tag=name $1`
  46. _UP_PRE="<![CDATA[]]>"
  47. _UP_POST="<![CDATA[]]>"
  48. _PKG_QUERY=`rpmextr --tag=name $1`
  49. _PKG_SIZE=`ls -l $1 | tr -s \  | cut -d \  -f 5`
  50. _PKG_ARCH=`echo $1 | tr . \\\\n | tail -n 2 | head -n 1`
  51. _PKG_ACTION="install"
  52. _PKG_VERSION=`rpmextr --tag=version $1`-`rpmextr --tag=release $1`
  53. _PKG_NAME=`rpmextr --tag=summary $1 | sed s/\&/and/g`
  54. _PKG_PRE="<![CDATA[]]>"
  55. _PKG_POST="<![CDATA[]]>"
  56.  
  57. #  echo \# $1
  58.  
  59.   cat << EOF
  60.  <updateset size="$_UP_SIZE" name="$_UP_NAME" >
  61.   <prescript>$_UP_PRE</prescript>
  62.   <postscript>$_UP_POST</postscript>
  63.   <package query="$_PKG_QUERY" size="$_PKG_SIZE" arch="$_PKG_ARCH"
  64.    action="$_PKG_ACTION" version="$_PKG_VERSION" name="$_PKG_NAME" >
  65.    <prescript>$_PKG_PRE</prescript>
  66.    <postscript>$_PKG_POST</postscript>
  67.   </package>
  68.  </updateset>
  69. EOF
  70.  
  71. }
  72.  
  73.  
  74. __createupdates_footer() {
  75.  
  76. cat << EOF
  77. </updatesets>
  78. EOF
  79.  
  80. }
  81.  
  82.   local filename FILES;
  83.  
  84.   __createupdates_header > $UPDATEBASEDIR/updatesets.xml
  85.  
  86.   FILES=`_getrpmlist $RPMSBASEDIR` || return 1
  87.  
  88.   for filename in $FILES; do
  89.     __createupdates_body $filename >> $UPDATEBASEDIR/updatesets.xml
  90.   done
  91.  
  92.   __createupdates_footer >> $UPDATEBASEDIR/updatesets.xml
  93.  
  94. }
  95.  
  96.  
  97. _signupdatesets_xml() {
  98.  
  99.   gpg --yes -sb $UPDATEBASEDIR/updatesets.xml || return 1
  100.  
  101. }
  102.  
  103.  
  104. _getlatestbuild() {
  105.  
  106.   echo -n What is the latest build \#\?\ 
  107.   read LATEST_BUILD
  108.  
  109. }
  110.  
  111.  
  112. _exit_error() {
  113.  
  114.   echo $* >&2
  115.   exit 1
  116.  
  117. }
  118.  
  119.  
  120. # main()
  121.  
  122. #  _getlatestbuild || _exit_error "could not get latest build #"
  123.   _createupdatesets_xml || _exit_error "could not create updatesets.xml file"
  124. #  _signupdatesets_xml || _exit_error "could not sign updatesets.xml file"
  125.  
  126. exit 0
  127.